/**
 * @author liangxi
 * @since 2023/12/21
 */

#ifndef DESIGNPATTERN_COFFEEWITHHOOK_H
#define DESIGNPATTERN_COFFEEWITHHOOK_H

#include "CaffeineBeverageWithHook.h"

namespace TemplateMethod_B {

    class CoffeeWithHook : public TemplateMethod_B::CaffeineBeverageWithHook {
    public:
        void brew() override {
            std::cout << "Dripping Coffee through filter" << std::endl;
        }

        void addCondiments() override {
            std::cout << "Adding Sugar and Milk" << std::endl;
        }

        bool customerWantsCondiments() override {
            auto answer = getUserInput();
            if (answer == "y") {
                return true;
            } else {
                return false;
            }
        }

        std::string getUserInput() {
            std::cout << "Would you like milk and sugar with your coffee(y/n)?" << std::endl;
            std::string answer;
            std::cin >> answer;
            if (answer.empty()) {
                answer = "no";
            }
            return answer;
        }

    };

} // TemplateMethod_B

#endif //DESIGNPATTERN_COFFEEWITHHOOK_H
